/*
	wxTradePost - A TradePost Calculator for Guild Wars 2
	Copyright (C) 2012 Scorcher24 <scorcher24@gmail.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "project.hpp"
#include "Application.hpp"
#include "Mainframe.hpp"

IMPLEMENT_APP(Application);

bool Application::OnInit()
{
	// Find the applications path
	m_app_path = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + wxFileName::GetPathSeparator();

	// Handlers for images and archives
	wxImage::AddHandler( new wxPNGHandler );
	wxFileSystem::AddHandler( new wxArchiveFSHandler );
	wxFileSystem::AddHandler( new wxZipFSHandler );

	// Init Resource System
	wxXmlResource::Get()->InitAllHandlers();

	// Load Resource File
	if ( wxXmlResource::Get()->Load(m_app_path + "/wxTradePostGUI.xrs") == false )
	{
		wxMessageBox(_("Cannot load Resource File! Please reinstall the Application!"), 
			wxMessageBoxCaptionStr, wxOK|wxICON_ERROR);
	}	

	// Create Mainframe, Center and add as top window
	Mainframe* f = new Mainframe();
	SetTopWindow(f);
    f->SetIcon(wxICON(ICON_AAAAAAA));
	f->Center();
	f->Show();
    

	// Done
	return true;
}